home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Memphis Amiga Group / MAG Disk (1990-09)(Memphis Amiga Group).zip / MAG Disk (1990-09)(Memphis Amiga Group).adf / sMOVIE / source / smovielines.c < prev    next >
C/C++ Source or Header  |  1989-12-29  |  2KB  |  94 lines

  1. /*    sMOVIElines.c - function to smooth scroll horizontal lines up
  2.                      through a view.
  3.                      M. J. Round.     7 - Oct - 1989.                    */
  4.  
  5.  
  6. /*  See sMOVIEtext.c for an explanation of how this works.    */
  7.  
  8.  
  9. #include "sMOVIE.h"
  10.  
  11. extern int maxfontheight,abort_prog;
  12.  
  13. extern int mousemonitor(void);
  14.  
  15. extern int maxwidth;
  16.  
  17. extern int delay;            /*    delay between each pixel scroll */
  18.  
  19. extern int ypos;            /*    y posn of previous text base    */
  20.  
  21. extern struct View v;        /*    view to be smooth scrolled        */
  22.  
  23. extern struct RastPort rp;    /*    rastport to write text to        */
  24.  
  25. void smoothlines (number,length,xpos,apen,bpen)
  26.  
  27. short number;            /*    number of lines to draw                        */
  28. short length;            /*    length of line (in pixels)                     */
  29. short xpos;             /*    x position to start line (in pixels)         */
  30. BYTE apen;              /*    foreground (ink colour) pen                  */
  31. BYTE bpen;              /*    background (paper colour) pen                */
  32.  
  33. {
  34.     int j,hipos,jump;
  35.     
  36.     register int i;
  37.  
  38.     WORD *ryoffset;
  39.     
  40.     ryoffset = &(v.ViewPort->RasInfo->RyOffset);
  41.     
  42.     jump = v.ViewPort->DHeight + maxfontheight;
  43.     
  44.     SetDrMd(&rp,JAM1);
  45.  
  46.     for(i=0; i < number; i++) {    /*  each pass scrolls one pixel    */
  47.         if (!abort_prog) abort_prog = mousemonitor();
  48.         else break;
  49.         
  50.         if (ypos >= (rp.BitMap->Rows - 6)) {
  51.             ypos -= jump;
  52.             *ryoffset -= jump;
  53.             }
  54.         hipos = ypos - jump;
  55.         Move (&rp,0,ypos);
  56.         if (xpos) {
  57.             SetAPen(&rp,bpen);
  58.             Draw (&rp,xpos,ypos);
  59.             }
  60.         SetAPen (&rp,apen);
  61.         Draw (&rp,xpos+length,ypos);
  62.         if (xpos+length < maxwidth-1) {
  63.             SetAPen (&rp,bpen);
  64.             Draw (&rp,maxwidth-1,ypos);
  65.             }
  66.         
  67.         if((hipos >= 0) && (*ryoffset >= hipos)) {
  68.             Move (&rp,0,hipos);
  69.             if (xpos) {
  70.                 SetAPen(&rp,bpen);
  71.                 Draw (&rp,xpos,hipos);
  72.                 }
  73.             SetAPen (&rp,apen);
  74.             Draw (&rp,xpos+length,hipos);
  75.             if (xpos+length < maxwidth-1) {
  76.                 SetAPen (&rp,bpen);
  77.                 Draw (&rp,maxwidth-1,hipos);
  78.                 }
  79.             }
  80.  
  81.         ++(*ryoffset);
  82.         MakeVPort(&v, v.ViewPort);
  83.         MrgCop(&v);
  84.  
  85.         for (j=0; j<delay; j++)
  86.             WaitTOF();
  87.  
  88.         LoadView(&v);            /* scroll up one pixel              */
  89.         
  90.         ypos++;
  91.         }                        /* repeat (number) times            */
  92.  
  93. }    /*  end of sMOVIElines    */
  94.